package com.rs.controller.Rs;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerDateModel;
import javax.swing.border.EmptyBorder;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.controller.Rs.DakaJFrame.SelectByDay;
import com.rs.controller.Rs.DakaJFrame.SelectRules;
import com.rs.model.Attendance;
import com.rs.model.AttendanceRules;
import com.rs.model.Department;
import com.rs.model.Position;
import com.rs.service.rs.DepartmentService;
import com.rs.util.DateChooserJButton;
import com.rs.util.DateFormatUtil;
import com.rs.util.Excel;
import com.rs.util.RiliAPI;
import com.rs.util.SpringContextUtils;

import jxl.write.WriteException;

public class DakaJFrame extends JFrame {
	
	private static final long serialVersionUID = 1L;
	
	private JPanel contentPane;

	 public class SelectByDay extends ZhiwuJFrame {
		   
		    private JPanel contentPane;
		    
		    private JTextField username;//姓名
		    
		    private JComboBox<String> state;//状态
		    
		    private JTextField daytime;//日期
		    
		    private Attendance aa;
		    
		    private Attendance a1;
			
		    private DepartmentService dts = SpringContextUtils.getBean(DepartmentService.class);


			
			private static final long serialVersionUID = 1L;
		
			public  SelectByDay(List<Attendance>ll,final int pages, final int yeshu, final int dangtian, final int type,final Attendance att) {
				super();
				//设置标题
				setTitle("考勤记录");
				//设置大小
				setBounds(500,300,920,500);
				//主体
				contentPane = new JPanel();
				contentPane.setBorder(new EmptyBorder(500,300,920,500));
				setContentPane(contentPane);
				contentPane.setLayout(null);
				//创建1个字体实bai例
				Font font = new Font("宋体", Font.PLAIN, 15);
				
				JLabel label = new JLabel("员工姓名：");
				label.setFont(font);
				label.setBounds(50,25,110,20);
		
				username = new JTextField();
				username.setBounds(130, 25, 100, 20);
				username.setColumns(10);
				
				JLabel label1 = new JLabel("状态：");
				label1.setFont(font);
				label1.setBounds(250,25,70,20);
		
				state = new JComboBox<String>();
				state.setBounds(300, 25, 100, 20);
				state.addItem(null);
				state.addItem("迟到");
				state.addItem("早退");
				state.addItem("缺卡");
				state.addItem("补卡");
				state.addItem("请假");
				state.addItem("出差");
				state.setFont(font);
				
				JLabel label2 = new JLabel("日期：");
				label2.setFont(font);
				label2.setBounds(450,25,70,20);
				
				daytime = new JTextField();
				daytime.setBounds(500, 25, 100, 20);
				daytime.setColumns(10);
				
//				final DateChooserJButton btnNewButton_4 = new DateChooserJButton();
//				  btnNewButton_4.addActionListener(new ActionListener() {
//				   public void actionPerformed(ActionEvent e) {
//				    SpinnerDateModel model = new SpinnerDateModel();
//				          JSpinner year = new JSpinner(model);
//				          year.setValue(new Date());
//				          JSpinner.DateEditor editor = new JSpinner.DateEditor(year,"yyyy-MM-dd");
//				          year.setEditor(editor);
//				          year.setBounds(500, 23, 50, 27);
//				   }
//				  });
//				  
//				  btnNewButton_4.setBounds(500, 23, 93, 20);
			   
				JButton tijiao = new JButton("查询");
				tijiao.setFont(font);
	            tijiao.setBounds(775, 25, 70, 20); 
	            JLabel uname = new JLabel("员工姓名");
	            uname.setFont(font);
	            uname.setBounds(20,65,70,20);
	            
	            JLabel zao1 = new JLabel("卯卡时间");
	            zao1.setFont(font);
	            zao1.setBounds(105,65,70,20);
	            
	            JLabel zao2 = new JLabel("卯卡状态");
	            zao2.setFont(font);
	            zao2.setBounds(190,65,70,20);
	            
	            JLabel yi1 = new JLabel("已卡时间");
	            yi1.setFont(font);
	            yi1.setBounds(275,65,70,20);
	            
	            JLabel yi2 = new JLabel("已卡状态");
	            yi2.setFont(font);
	            yi2.setBounds(360,65,70,20);
	            
	            JLabel wu1 = new JLabel("午卡时间");
	            wu1.setFont(font);
	            wu1.setBounds(445,65,70,20);
	            
	            JLabel wu2 = new JLabel("午卡状态");
	            wu2.setFont(font);
	            wu2.setBounds(530,65,70,20);
	            
	            JLabel wan1 = new JLabel("申卡时间");
	            wan1.setFont(font);
	            wan1.setBounds(615,65,70,20);
	            
	            JLabel wan2 = new JLabel("申卡状态");
	            wan2.setFont(font);
	            wan2.setBounds(700,65,70,20);
	            
	            JLabel riqi = new JLabel("日     期");
	            riqi.setFont(font);
	            riqi.setBounds(785,65,70,20);
	            
	            JButton shang = new JButton("上一页");
	            shang.setFont(font);
	            shang.setBounds(590, 400, 90, 20);
	            
	            JButton xia = new JButton("下一页");
	            xia.setFont(font);
	            xia.setBounds(710, 400, 90, 20);
	            
	            JButton qian = new JButton("上一天");
	            qian.setFont(font);
	            qian.setBounds(100, 400, 90, 20);
	            
	            JButton hou = new JButton("下一天");
	            hou.setFont(font);
	            hou.setBounds(210, 400, 90, 20);

	            JButton dang = new JButton("当天");
	            dang.setFont(font);
	            dang.setBounds(320, 400, 90, 20);
	            
	            contentPane.add(tijiao);  
				contentPane.add(label);
				contentPane.add(username);
				contentPane.add(label1);
				contentPane.add(state);
				contentPane.add(label2);
				contentPane.add(daytime);
				contentPane.add(zao1);
				contentPane.add(zao2);
				contentPane.add(yi1);
				contentPane.add(yi2);
				contentPane.add(wu1);
				contentPane.add(wu2);
				contentPane.add(wan1);
				contentPane.add(wan2);
				contentPane.add(uname);
				contentPane.add(shang);
				contentPane.add(xia);
				contentPane.add(qian);
				contentPane.add(hou);
				contentPane.add(dang);
				contentPane.add(riqi);
				
				tijiao.addActionListener(new ActionListener() {
	    			@Override
	    			public void actionPerformed(ActionEvent e) {
	    				Attendance a2 = new Attendance();
	    				String u_name = username.getText();
	    				String states = (String) state.getSelectedItem();
	    				String day = daytime.getText();
	    				
	    					a2.setAt_days(day);	    				
	    					a2.setU_name(u_name);
	    					a2.setState(states);
	    				
	    				Page<Attendance> page = PageHelper.startPage(1, 10);
	    				int yeshu = 1;
	    				int type = 2;
	    				List<Attendance> ll = dts.selectByTiaojian(a2);
	    				int pages = page.getPages();
	    				dispose();
	    				new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,a2).setVisible(true);	
	    			}
	    		});
	    			
				
	    			
				qian.addActionListener(new ActionListener() {

					@Override
	    			public void actionPerformed(ActionEvent e) {
						a1 = new Attendance();
						int w = dangtian-1;
						a1.setPageSize(w);
						Page<Attendance> page = PageHelper.startPage(1, 10);
    	    				int yeshu = 1;
    	    				int type = 3;
    						List<Attendance> ll = dts.attendanceFindByDay(a1);
    						int pages = page.getPages();
    						if(ll.size()==0) {
    							showMessageDialog("当前条件没有更多记录");
    						}else {
    							dispose();
    	    	    			new DakaJFrame().new SelectByDay(ll,pages,yeshu,w,type,aa).setVisible(true);
    						}
	    			}
	    		});
				hou.addActionListener(new ActionListener() {
					@Override
	    			public void actionPerformed(ActionEvent e) {
						a1 = new Attendance();
						int q = dangtian + 1;
						a1.setPageSize(q);
						Page<Attendance> page = PageHelper.startPage(1, 10);
    	    				int yeshu = 1;
    	    				int type = 3;
    						List<Attendance> ll = dts.attendanceFindByDay(a1);
    						int pages = page.getPages();
    						if(ll.size()==0) {
    							showMessageDialog("当前条件没有更多记录");
    						}else {
    							dispose();
    	    	    			new DakaJFrame().new SelectByDay(ll,pages,yeshu,q,type,aa).setVisible(true);
    						}
	    			}
	    		});
				
				dang.addActionListener(new ActionListener() {

					@Override
	    			public void actionPerformed(ActionEvent e) {
						
						Page<Attendance> page = PageHelper.startPage(1, 10);
						int yeshu = 1;
						int type = 1;
						List<Attendance> ll = dts.attendanceSelectByDay();
						int pages = page.getPages();
						dispose();
						new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,aa).setVisible(true);
	    			}
	    		});
				
				shang.addActionListener(new ActionListener() {

					@Override
	    			public void actionPerformed(ActionEvent e) {
						
	    				if(yeshu==1) {
	    					showMessageDialog("当前条件没有更多记录");
	    				}else{
	    					int xin = yeshu-1;
	    					Page<Attendance> page = PageHelper.startPage(xin, 10);
	    					if(type==1) {
	    	    				int yeshu = xin;
	    	    				int type = 1;
	    						List<Attendance> ll = dts.attendanceSelectByDay();
	    						int pages = page.getPages();
	    						dispose();
	    	    				new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,aa).setVisible(true);	
	    					}else if(type==2){
	    	    				int yeshu = xin;
	    	    				int type = 2;
	    						List<Attendance> ll = dts.selectByTiaojian(att);
	    						int pages = page.getPages();
	    						dispose();
	    	    				new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,att).setVisible(true);	
	    					}else {
	    						int yeshu = xin;
	    	    				int type = 3;
	    	    				int e1 = dangtian;
	    	    				a1 = new Attendance();
	    	    				a1.setPageSize(e1);
	    						List<Attendance> ll = dts.attendanceFindByDay(a1);
	    						int pages = page.getPages();
    							dispose();
    	    	    			new DakaJFrame().new SelectByDay(ll,pages,yeshu,e1,type,aa).setVisible(true);
	    					}
	    				}
	    			}
	    		});
				
				xia.addActionListener(new ActionListener() {

					@Override
	    			public void actionPerformed(ActionEvent e) {
	    				if(yeshu==pages) {
	    					showMessageDialog("当前条件没有更多记录");
	    				}else{
	    					dispose();
	    					int xin = yeshu+1;
	    					Page<Attendance> page = PageHelper.startPage(xin, 10);
	    					if(type==1) {
	    	    				int yeshu = xin;
	    	    				int type = 1;
	    						List<Attendance> ll = dts.attendanceSelectByDay();
	    						int pages = page.getPages();
//	    						System.out.println(yeshu);
	    						dispose();
	    	    				new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,aa).setVisible(true);	
	    					}else if(type==2){
	    	    				int yeshu = xin;
	    	    				int type = 2;
	    						List<Attendance> ll = dts.selectByTiaojian(att);
	    						int pages = page.getPages();
	    						dispose();
	    	    				new DakaJFrame().new SelectByDay(ll,pages,yeshu,0,type,att).setVisible(true);	
	    					}else {
	    						int yeshu = xin;
	    						int type = 3;
	    	    				int e1 = dangtian;
	    	    				a1 = new Attendance();
	    	    				a1.setPageSize(e1);
	    						List<Attendance> ll = dts.attendanceFindByDay(a1);
	    						int pages = page.getPages();
    							dispose();
    	    	    			new DakaJFrame().new SelectByDay(ll,pages,yeshu,e1,type,aa).setVisible(true);
	    					}
	    				}
	    			}
	    		});	
				for(int i=0;i<ll.size();i++) {
					final Attendance l1 = ll.get(i);
					
					int a = l1.getAt_amtype();
					String a1 = "-";
					int b = l1.getAt_noontype();
					String b1 = "-";
					int c = l1.getAt_pmtype();
					String c1 = "-";
					int d = l1.getat_nighttype();
					String d1 = "-";
					if(a==1) {
						a1="√";
					}else if(a==2) {
						a1="※";
					}else if(a==3) {
						a1="∑";
					}else if(a==4) {
						a1="■";
					}else if(a==5) {
						a1="△";
					}else if(a==6) {
						a1="▲";
					}else if(a==7) {
						a1="∞";
					}else if(a==8) {
						a1="∫";
					}else if(a==9) {
						a1="∮";
					}else if(a==10) {
						a1="○";
					}else if(a==11) {
						a1="⊙";
					}
					if(b==1) {
						b1="√";
					}else if(b==2) {
						b1="※";
					}else if(b==3) {
						b1="∑";
					}else if(b==4) {
						b1="■";
					}else if(b==5) {
						b1="△";
					}else if(b==6) {
						b1="▲";
					}else if(b==7) {
						b1="∞";
					}else if(b==8) {
						b1="∫";
					}else if(b==9) {
						b1="∮";
					}else if(b==10) {
						b1="○";
					}else if(b==11) {
						b1="⊙";
					}
					if(c==1) {
						c1="√";
					}else if(c==2) {
						c1="※";
					}else if(c==3) {
						c1="∑";
					}else if(c==4) {
						c1="■";
					}else if(c==5) {
						c1="△";
					}else if(c==6) {
						c1="▲";
					}else if(c==7) {
						c1="∞";
					}else if(c==8) {
						c1="∫";
					}else if(c==9) {
						c1="∮";
					}else if(c==10) {
						c1="○";
					}else if(c==11) {
						c1="⊙";
					}
					if(d==1) {
						d1="√";
					}else if(d==2) {
						d1="※";
					}else if(d==3) {
						d1="∑";
					}else if(d==4) {
						d1="■";
					}else if(d==5) {
						d1="△";
					}else if(d==6) {
						d1="▲";
					}else if(d==7) {
						d1="∞";
					}else if(d==8) {
						d1="∫";
					}else if(d==9) {
						d1="∮";
					}else if(d==10) {
						d1="○";
					}else if(d==11) {
						d1="⊙";
					}
					
					Date amtime = l1.getAt_amtime();
					Date noon = l1.getAt_noontime();
					Date pmtime = l1.getAt_pmtime();
					Date night = l1.getAt_nighttime();
					String a2 = "";
					String b2 = "";
					String c2 = "";
					String d2 = "";
					if(null==amtime || amtime.equals("")) {
						a2="-";
						JLabel label4 = new JLabel(a2);
						label4.setFont(font);
						label4.setBounds(125,65+25*(i+1),100,20);
						contentPane.add(label4);
					}else{
						a2 = new DateFormatUtil().getDateString(l1.getAt_amtime(),"HH:mm:ss");
						JLabel label4 = new JLabel(a2);
						label4.setFont(font);
						label4.setBounds(105,65+25*(i+1),100,20);
						contentPane.add(label4);
					}
					if(null==noon || noon.equals("")) {
						b2="-";
						JLabel label6 = new JLabel(b2);
						label6.setFont(font);
						label6.setBounds(305,65+25*(i+1),100,20);
						contentPane.add(label6);
					}else {
						b2 = new DateFormatUtil().getDateString(l1.getAt_noontime(),"HH:mm:ss");
						JLabel label6 = new JLabel(b2);
						label6.setFont(font);
						label6.setBounds(275,65+25*(i+1),100,20);
						contentPane.add(label6);
					}
					if(null==pmtime || pmtime.equals("")) {
						c2="-";
						JLabel label8 = new JLabel(c2);
						label8.setFont(font);
						label8.setBounds(475,65+25*(i+1),100,20);
						contentPane.add(label8);
					}else {
						c2= new DateFormatUtil().getDateString(l1.getAt_pmtime(),"HH:mm:ss");
						JLabel label8 = new JLabel(c2);
						label8.setFont(font);
						label8.setBounds(445,65+25*(i+1),100,20);
						contentPane.add(label8);
					}
					if(null==night || night.equals("")) {
						d2="-";
						JLabel label10 = new JLabel(d2);
						label10.setFont(font);
						label10.setBounds(645,65+25*(i+1),100,20);
						contentPane.add(label10);
					}else {
						d2 = new DateFormatUtil().getDateString(l1.getAt_nighttime(),"HH:mm:ss");
						JLabel label10 = new JLabel(d2);
						label10.setFont(font);
						label10.setBounds(615,65+25*(i+1),100,20);
						contentPane.add(label10);
					}
					JLabel label3 = new JLabel(l1.getU_name());
					label3.setFont(font);
					label3.setBounds(20,65+25*(i+1),70,20);
					contentPane.add(label3);
					
					JLabel label5 = new JLabel(a1);
					label5.setFont(font);
					label5.setBounds(220,65+25*(i+1),70,20);
					contentPane.add(label5);
					
					JLabel label7 = new JLabel(b1);
					label7.setFont(font);
					label7.setBounds(380,65+25*(i+1),70,20);
					contentPane.add(label7);
					
					JLabel label9 = new JLabel(c1);
					label9.setFont(font);
					label9.setBounds(560,65+25*(i+1),70,20);
					contentPane.add(label9);
					
					JLabel label11 = new JLabel(d1);
					label11.setFont(font);
					label11.setBounds(730,65+25*(i+1),70,20);
					contentPane.add(label11);
					
					JLabel label12 = new JLabel(new DateFormatUtil().getDateString(l1.getAt_day(),"yyyy-MM-dd"));
					label12.setFont(font);
					label12.setBounds(785,65+25*(i+1),90,20);
					contentPane.add(label12);
				}	
		}		
			
	}
	 
	 public class SelectRules extends ZhiwuJFrame {
		  
			private JPanel contentPane;
		  
			private JTextField zao;
			private JTextField zhong;
			private JTextField wu;
			private JTextField wan;
			
		    private DepartmentService dts = SpringContextUtils.getBean(DepartmentService.class);
			
			private static final long serialVersionUID = 1L;
			
			public SelectRules(final AttendanceRules att) {
					// TODO Auto-generated constructor stub
				super();
				//设置标题
				setTitle("考勤记录");
				//设置大小
				setBounds(500,300,250,250);
				//主体
				contentPane = new JPanel();
				contentPane.setBorder(new EmptyBorder(500,300,250,250));
				setContentPane(contentPane);
				contentPane.setLayout(null);
				//创建1个字体实bai例
				Font font = new Font("宋体", Font.PLAIN, 15);
				 
	            JLabel zao1 = new JLabel("卯卡时间：");
	            zao1.setFont(font);
	            zao1.setBounds(20,25,100,20);
	            
	            zao = new JTextField(att.getAtru_am());
				zao.setBounds(110, 25, 100, 20);
				zao.setColumns(10);
				
				JLabel zhong1 = new JLabel("已卡时间：");
				zhong1.setFont(font);
				zhong1.setBounds(20,55,100,20);
	            
				zhong = new JTextField(att.getAtru_noon());
				zhong.setBounds(110, 55, 100, 20);
				zhong.setColumns(10);
				
				JLabel wu1 = new JLabel("午卡时间：");
				wu1.setFont(font);
				wu1.setBounds(20,85,100,20);
	            
	            wu = new JTextField(att.getAtru_pm());
				wu.setBounds(110, 85, 100, 20);
				wu.setColumns(10);
				
				JLabel wan1 = new JLabel("申卡时间：");
				wan1.setFont(font);
				wan1.setBounds(20,115,100,20);
	            
				wan = new JTextField(att.getAtru_night());
				wan.setBounds(110, 115, 100, 20);
				wan.setColumns(10);
				
				JButton xiugai = new JButton("修改规则");
				xiugai.setFont(font);
				xiugai.setBounds(70, 155, 100, 20); 
				
				contentPane.add(zao);
				contentPane.add(zao1);
				contentPane.add(zhong);
				contentPane.add(zhong1);
				contentPane.add(wu);
				contentPane.add(wu1);
				contentPane.add(wan);
				contentPane.add(wan1);
				contentPane.add(xiugai);
				xiugai.addActionListener(new ActionListener() {
	    			@Override
	    			public void actionPerformed(ActionEvent e) {
	    				Object[] options = {"是(Y)","否(N)"};
	    	            int a = JOptionPane.showOptionDialog(null,"您确定要修改规则吗？","提醒",
	    	    	            JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,options,options[0]);
	    	    	            if(a==1) {
	    	    	            	return;
	    	    	            }else if(a==0){
	    	    	            	AttendanceRules att1 = new AttendanceRules();
	    	    	            	att1.setAtru_am(zao.getText());
	    	    	            	att1.setAtru_noon(zhong.getText());
	    	    	            	att1.setAtru_pm(wu.getText());
	    	    	            	att1.setAtru_night(wan.getText());
	    	    	            	att1.setAtru_id(att.getAtru_id());
	    	    	            	dts.updateByPrimaryKey(att1);
	    	    	            	showMessageDialog("修改成功");
	    	    	            	 dispose();
	 			    				AttendanceRules att2 = dts.attendanceRulesFind();
	 			    				new DakaJFrame().new SelectRules(att2).setVisible(true);
	    	    	            }
	    				       
	    			}
	    		});
			}
	 }
			 public class Daochu extends ZhiwuJFrame {
				 
					private JPanel contentPane;

					private static final long serialVersionUID = 1L;
					
					private JTextField wjm;
					
					private JComboBox<Integer> years;//年份
					
					private JComboBox<Integer> months;//月份
					
					private DepartmentService dts = SpringContextUtils.getBean(DepartmentService.class);
					
					public Daochu() {
						super();
						//设置标题
						setTitle("导出考勤记录");
						//设置大小
						setBounds(250, 50, 300, 200);
						//主体
						contentPane = new JPanel();
						setContentPane(contentPane);
						contentPane.setLayout(null);

						//创建1个字体实bai例
						Font font = new Font("宋体", Font.PLAIN, 15);

						JLabel names = new JLabel("文件名：");
						JLabel  a  = new JLabel("年份 ：");
						JLabel  b  = new JLabel("月份 ：");

						names.setFont(font);
						names.setBounds(50, 25, 120, 20);
						a.setFont(font);
						a.setFont(font);
						a.setBounds(50, 50, 120, 20);
						b.setFont(font);
						b.setBounds(50, 75, 120, 20);
						wjm = new JTextField();
						wjm.setBounds(140, 25, 100, 20);
						wjm.setColumns(10);
						years = new JComboBox<Integer>();
						years.addItem(null);
						for(int i =2017;i<2021;i++) {
							years.addItem(i);
						}
						years.setBounds(140, 50, 100, 22);
						years.setFont(font);
						months = new JComboBox<Integer>();
						months.addItem(null);
						for(int i =1;i<13;i++) {
							months.addItem(i);
						}
						months.setBounds(140, 75, 100, 22);
						months.setFont(font);
						JButton tijiao = new JButton("导出");
						tijiao.setFont(font);
			            tijiao.setBounds(170, 100, 70, 20);
			            contentPane.add(a);
			            contentPane.add(b);
			            contentPane.add(years);
			            contentPane.add(months);
			            contentPane.add(tijiao);
			            contentPane.add(names);
			            contentPane.add(wjm);
			            tijiao.addActionListener(new ActionListener() {
			    			@Override
			    			public void actionPerformed(ActionEvent e) {
			    				Object year= years.getSelectedItem();
			    				Object month= months.getSelectedItem();
			    				int week = 0;
			    				if(year.equals(null)) {
			    					showMessageDialog("年份不能为空");
			    				}else if(months.equals(null)) {
			    					showMessageDialog("月份不能为空");
			    				}else {
			    					int a = (int)year;
			    					int b = (int)month;
			    					String w = "";
			    					if (b<10) {
  		    					    	 w = year+"-0"+month;
  		    					    }else {
  		    					         w = year+"-"+month;
  		    					    }
			    					Attendance a1 = new Attendance();
			    					a1.setMonth(w);
			    					List<Attendance> ll = dts.attendanceFindAllname(a1);//获取该月份所有打卡人的姓名
			    					if(ll.size()==0) {
			    						showMessageDialog("没有该月份的记录");
			    					}else {
			    						List<Attendance> l1 = dts.attendanceFindAll(a1);//获取该月份所有打卡记录
			    						String c = "";
	   		    					    int tianshu = RiliAPI.getDayOfMonth(a, b);
	   		    					    if (b<10) {
	   		    					    	 c = "key=48f65dafdbd1d882a8b67fc86c677cf5&date="+year+"-0"+month+"-"+"01";
	   		    					    }else {
	   		    					         c = "key=48f65dafdbd1d882a8b67fc86c677cf5&date="+year+"-"+month+"-"+"01";
	   		    					    }
	   		    					    System.out.println("ccccc"+c);
	   		    					    String result = RiliAPI.request(c);
	   		    					    String e1 = result.substring(result.indexOf("\"cnweekday\":\"星期")+15);
	   		    					    String e2 = e1.substring(0,1);
	   		    					    if(e2.equals("一")) {
	   		    					    	week = 1;
	   		    					    }else if(e2.equals("二")) {
	   		    					    	week = 2;
	   		    					    }else if(e2.equals("三")) {
	   		    					    	week = 3;
	   		    					    }else if(e2.equals("四")) {
	   		    					    	week = 4;
	   		    					    }else if(e2.equals("五")) {
	   		    					    	week = 5;
	   		    					    }else if(e2.equals("六")) {
	   		    					    	week = 6;
	   		    					    }else if(e2.equals("日")) {
	   		    					    	week = 7;
	   		    					    }
	   		    					try {
	   		    						System.out.println(wjm+"wjm");
	   		    						System.out.println(tianshu+"tianshu");
	   		    						System.out.println(week+"week");
										Excel.aa(wjm.getText(),tianshu,wjm.getText(),week,ll,l1);
										showMessageDialog("导出成功，存储位置为：D:\\");
									} catch (WriteException | IOException e3) {
										// TODO Auto-generated catch block
										e3.printStackTrace();
									}
			    					}
			    					
			    				}
			    			    
			    			}
			    		});
					}	
				}
				 
	
	//提示弹窗
		 public void showMessageDialog(String massage){
		  JOptionPane.showMessageDialog(this,massage);
		 }
}
